<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        img {
            width: 600px;
        }
    </style>
</head>
<body>
    <img src="" alt="">
    <script>
        var date = new Date()
        time = date.getHours()
        var img = document.querySelector('img')
        if (time < 12 ) {
            img.src = 'goodmorning.jpeg'
        }else if (time < 18) {
            img.src = 'goodnoon.jpg'
        }else if (time < 24){
            img.src = 'goodnight.jpg'
        }
        console.log(time);
    </script>
</body>
</html>